package com.ms;

/**
 * & 和 && 的区别 ？
 * & 位与预算 ,逻辑与运算，没有短路运算 ；
 * && 逻辑符号and , 有短路操作，不改变原值；
 *
 * @author carter
 * create time    2018-08-20
 */
public class TestAnd {

    public static void main(String[] args) {

        System.out.println(""+ (3 & 5));//1

        int a = 1 ;
        int b=2;
        if ((a == 2) && ((b = 3) == 5))
        {
            System.out.println("exe");
        }

        System.out.println(a);//1
        System.out.println(b);//2

        System.out.println("==================");

        if ((a == 2) & ((b = 3) == 5))
        {
            System.out.println("exe");
        }


        System.out.println(a);//1
        System.out.println(b);//3

        System.out.println("==================");
        if ((a == 1) && ((b = 3) == 5))
        {
            System.out.println("exe");
        }

        System.out.println(a);//1
        System.out.println(b);//3

    }

}
